import Vue from 'vue'
import upperFirst from 'lodash/upperFirst'
import camelCase from 'lodash/camelCase'
import * as filters from '@/config/filters'
import global from '@/config/global'
Vue.mixin(global)
Object.entries(filters).forEach(function (item) {
  Vue.filter(item[0], item[1])
})
const requireComponent = require.context('@/components/basic', false, /\w+\.(vue|js)$/)
requireComponent.keys().forEach(fileName => {
  // 获取组件配置
  const componentConfig = requireComponent(fileName)
  // 获取组件的 PascalCase 命名
  const componentName = upperFirst(camelCase(fileName.replace(/^\.\/(.*)\.\w+$/, '$1')))
  // 全局注册组件
  Vue.component(componentName, componentConfig.default || componentConfig)
})
